package top.healthylife.gateway.platform.geo.api.api.z4;

import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.core.util.SystemConfigUtils;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.geo.api.config.SystemConfig;
import top.healthylife.gateway.platform.geo.api.util.client.ClientUtil;
import top.healthylife.gateway.platform.geo.dto.z4.req.GeoReqCheck4FactorOnBankCardDto;
import top.healthylife.gateway.platform.geo.dto.z4.res.GeoResCheck4FactorOnBankCardDto;

import java.util.Map;

/**
 * @author : GaoZeXi
 * @date 2021/3/25 18:02
 */
@Slf4j
@Service
@ApiServiceExplain(price = 20,docUrl ="-",apiName = "银行卡四要素验证-Z4", info = "说明：1、覆盖三网。2、code=200,且RSL有值收费。")
public class GeoResCheck4FactorOnBankCardApi implements ParentFace<GeoReqCheck4FactorOnBankCardDto, GeoResCheck4FactorOnBankCardDto> {
    static String url = "http://yz.geotmt.com/civp/getview/api/u/queryUnify";

    static String innerIfType = "Z4";

    @Override
    public GeoResCheck4FactorOnBankCardDto execute(GeoReqCheck4FactorOnBankCardDto dto) throws Exception {
        SystemConfig o = (SystemConfig) SystemConfigUtils.get();
        return ClientUtil.getApiData(url, buildMap(dto),o, GeoResCheck4FactorOnBankCardDto.class);
    }

    public Map<String,Object> buildMap(GeoReqCheck4FactorOnBankCardDto dto){
        Map<String, Object> stringObjectMap = BeanUtil.beanToMap(dto);
        stringObjectMap.put("innerIfType",innerIfType);
        return stringObjectMap;
    }
}
